package com.nulldev.util.net.experimental.groupedudp.datagrams;

import java.net.DatagramPacket;

import com.nulldev.util.net.experimental.groupedudp.DatagramTypes;
import com.nulldev.util.net.experimental.groupedudp.Encryptor;
import com.nulldev.util.net.packets.NetPacket;
import com.nulldev.util.net.packets.PacketManager;

public class nPacketGram extends ADatagram {
	
	private byte[] packetData;

	protected nPacketGram() {
		super(Encryptor.DUMMY, DatagramTypes.NPACKET_SYSTEM_PACKET);
	}

	public nPacketGram(final DatagramPacket datagram) {
		super(Encryptor.DUMMY, DatagramTypes.NPACKET_SYSTEM_PACKET);
		this.packetData = unpackAndDecrypt(datagram);
	}
	
	public NetPacket get() {
		return PacketManager.parsePacket(null, null, new String(this.packetData));
	}

}
